/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * ScrollTest.java
 *
 * Created on Sep 17, 2009, 1:12:38 PM
 */
package GeneralTesting;

import DragBarPanelPackage.DragBarPanel;
import java.awt.Color;
import java.awt.Dimension;
import javax.swing.GroupLayout;
import javax.swing.JPanel;
import javax.swing.JScrollPane;

/**
 *
 * @author Heather
 */
public class ScrollTest extends javax.swing.JApplet
{

  /** Initializes the applet ScrollTest */
  public void init()
  {
    try
    {
      java.awt.EventQueue.invokeAndWait(new Runnable()
      {

        public void run()
        {
          initComponents();
        }
      });
    } catch (Exception ex)
    {
      ex.printStackTrace();
    }
  }

  /** This method is called from within the init() method to
   * initialize the form.
   * WARNING: Do NOT modify this code. The content of this method is
   * always regenerated by the Form Editor.
   */
  @SuppressWarnings("unchecked")
  // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
  private void initComponents() {

    jPanel1 = new javax.swing.JPanel();
    jButton1 = new javax.swing.JButton();
    tabPane = new javax.swing.JTabbedPane();
    blahPanel = new javax.swing.JPanel();
    scrollPane = new javax.swing.JScrollPane();
    boogy = new javax.swing.JPanel();

    jPanel1.setBackground(new java.awt.Color(255, 255, 204));
    jPanel1.setLayout(null);

    jButton1.setText("add");
    jButton1.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        jButton1ActionPerformed(evt);
      }
    });
    jPanel1.add(jButton1);
    jButton1.setBounds(30, 330, 350, 130);

    blahPanel.setBackground(new java.awt.Color(204, 255, 204));

    scrollPane.setBackground(new java.awt.Color(255, 204, 204));
    scrollPane.setAutoscrolls(true);

    boogy.setBackground(new java.awt.Color(153, 255, 204));

    javax.swing.GroupLayout boogyLayout = new javax.swing.GroupLayout(boogy);
    boogy.setLayout(boogyLayout);
    boogyLayout.setHorizontalGroup(
      boogyLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGap(0, 343, Short.MAX_VALUE)
    );
    boogyLayout.setVerticalGroup(
      boogyLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGap(0, 240, Short.MAX_VALUE)
    );

    scrollPane.setViewportView(boogy);

    javax.swing.GroupLayout blahPanelLayout = new javax.swing.GroupLayout(blahPanel);
    blahPanel.setLayout(blahPanelLayout);
    blahPanelLayout.setHorizontalGroup(
      blahPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addComponent(scrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 345, Short.MAX_VALUE)
    );
    blahPanelLayout.setVerticalGroup(
      blahPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addComponent(scrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 242, Short.MAX_VALUE)
    );

    tabPane.addTab("tab1", blahPanel);

    jPanel1.add(tabPane);
    tabPane.setBounds(30, 30, 350, 270);

    javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
    getContentPane().setLayout(layout);
    layout.setHorizontalGroup(
      layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, 797, Short.MAX_VALUE)
    );
    layout.setVerticalGroup(
      layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, 498, Short.MAX_VALUE)
    );
  }// </editor-fold>//GEN-END:initComponents

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_jButton1ActionPerformed
    {//GEN-HEADEREND:event_jButton1ActionPerformed
      DragBarPanel newDragBarPanel = new DragBarPanel(5);
      newDragBarPanel.setSize(bigSize);
      
      // the container for the drag bar button
      JPanel dbpContainer = new JPanel();
      //dbpContainer.setLayout(new GroupLayout(dbpContainer));
      dbpContainer.setLayout(null);
      dbpContainer.updateUI();
      dbpContainer.setBackground(Color.red);
      dbpContainer.setSize(bigSize);
      dbpContainer.setPreferredSize(bigSize);
      dbpContainer.add(newDragBarPanel);

      // TODO add your handling code here:
      // create a panel for this new tab
      JPanel newTabPanel = new JPanel();
      //newTabPanel.setLayout(new GroupLayout(newTabPanel));
      newTabPanel.setLayout(null);
      newTabPanel.updateUI();
      newTabPanel.setBackground(Color.red);
      newTabPanel.setSize(contSize);
      newTabPanel.setPreferredSize(contSize);
      
      // scroll pane for the new tab
      JScrollPane sp = new JScrollPane(dbpContainer);
      System.out.println(dbpContainer.getSize());
      //sp.setLayout(new GroupLayout(sp));
      sp.updateUI();
      sp.setBackground(Color.red);
      sp.setSize(smallSize);
      sp.setPreferredSize(smallSize);
      sp.setAutoscrolls(true);
      newTabPanel.add(sp);
      //sp.setViewportView(dbpContainer);
      //sp.add(dbpContainer);

      // now that the tracker is setup and we have the panel, add a new tab
      tabPane.addTab("booga", newTabPanel);
      boogy.setSize(bigSize);
      boogy.setPreferredSize(bigSize);
    }//GEN-LAST:event_jButton1ActionPerformed
  // Variables declaration - do not modify//GEN-BEGIN:variables
  private javax.swing.JPanel blahPanel;
  private javax.swing.JPanel boogy;
  private javax.swing.JButton jButton1;
  private javax.swing.JPanel jPanel1;
  private javax.swing.JScrollPane scrollPane;
  private javax.swing.JTabbedPane tabPane;
  // End of variables declaration//GEN-END:variables
  private JPanel tPanel = new JPanel();
  private Dimension contSize = new Dimension(350, 270);
  private Dimension smallSize = new Dimension(340, 220);
  private Dimension bigSize = new Dimension(600, 270);
}
